/**
 * 
 */
package com.an.framework;

import javax.servlet.FilterRegistration;
import javax.servlet.ServletContext;

import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;
import org.springframework.web.filter.CharacterEncodingFilter;

/**
 * @author Administrator 这个类的目的是注册SpringSecurityFilterChain
 */
public class SecurityWebApplicationIntializer extends AbstractSecurityWebApplicationInitializer  {

	/**
	 * 设置编码过滤器，解决乱码.
	 * 
	 * @see org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer#
	 *      beforeSpringSecurityFilterChain(javax.servlet.ServletContext)
	 */
	@Override
	protected void beforeSpringSecurityFilterChain(ServletContext servletContext) {
		FilterRegistration.Dynamic characterEncodingFilter = servletContext.addFilter("encodingFilter",
				new CharacterEncodingFilter());
		characterEncodingFilter.setInitParameter("encoding", "UTF-8");
		characterEncodingFilter.setInitParameter("forceEncoding", "true");
		characterEncodingFilter.addMappingForUrlPatterns(null, false, "/*");
	}
	
	
}
